﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Report : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            stockgrid();
            detailedStock();
        }
    }

    public void stockgrid()
    {

        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        SqlCommand cmd = new SqlCommand("select ID,Product,Brand,Series,Salesperson from MAS_tInventryDetails where STATUS in ('Ordered','Processed'); ", con);
        cmd.CommandType = CommandType.Text;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        con.Open();
        sda.Fill(ds);
        con.Close();
        GridView4.DataSource = ds;
        GridView4.DataBind();

    }



    protected void GridView4_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView4.PageIndex = e.NewPageIndex;
        stockgrid();
    }

    public void detailedStock()
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        SqlCommand cmd = new SqlCommand("select Salesperson,COUNT(Salesperson) As countVa from MAS_tInventryDetails where STATUS in ('Ordered','Processed') group by Salesperson; ", con);
        cmd.CommandType = CommandType.Text;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        con.Open();
        sda.Fill(ds);
        con.Close();
        GridView5.DataSource = ds;
        GridView5.DataBind();
     
    }

    protected void GridView5_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView5.PageIndex = e.NewPageIndex;
        detailedStock();
    }


}